home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 5
/
005.d81
/
dos part 10
< prev
next >
Wrap
Text File
|
2022-08-26
|
3KB
|
193 lines
Dos & Don'ts --- Part 10
by Joel Ellis Rea
--------------------------------------
To use a channel on the disk drive,
you must use BASIC's OPEN command.
The OPEN command wants three numeric
parameters and a string parameter.
eg: open6,8,6,"houses"
The first parameter is the Logical
File Number, which is simply an
arbitrary number from 0 to 255 that
is used by your program to identify
the file from when you OPEN it until
you CLOSE it. For now, avoid numbers
larger than 127.
The second parameter is the First
Address, which is actually the device
number. For disk drives, the First
Address can be 8, 9, 10, or 11. If
you have only one drive unit, it is
almost always First Address #8.
The third parameter is the Second
Address. It is a number from 0 to 31
which passes additional information to
the device specified in the First
Address. In the case of disk drives,
the Second Address is the channel
number, plain and simple!
So, if we wanted to OPEN the
Command/Error channel of drive unit 8
as file #10, the command would be:
OPEN 10, 8, 15
where 15 means channel #15, the
Command/Error channel.
The OPEN command can also take a
string parameter after the three
numbers. This string is passed to the
device immediately, with a special
signal attached. For devices such as
printers, the string is simply
considered to be the same as any other
data. The disk drive, however, uses
it as a file name when a data channel
is OPENed. If the Command/Error
channel is OPENed, the string can
contain a command. One command that
is good to use is the Initialize
command, which verifies that a
Commodore 1541-format disk is in the
drive. So, a useful command to open
the Command/Error channel might be:
OPEN 15, 8, 15, "I0"
This time we used a Logical File
Number of 15 to help remind us that
this is, indeed, the Command/Error
channel.
Now that the channel is OPEN, what
can you do with it? Well, any DOS
Maintenance command can be sent to the
disk drive via this channel. By using
the PRINT# command, data is sent to
the file specified by the Logical
File Number followint the '#' in the
PRINT# command. That means you can
send most normal Wedge commands using
OPEN15,8,15 and PRINT#15. Except for
@$ (Directory), @ (Disk Status, [more
later]), @#n (to change the First
Address used by the Wedge to 'n'), and
@Q (to disable the Wedge).
For example, we can programmatically
scratch all files whose name starts
with the letter 'Z' by executing a
command such as PRINT #15, "S:Z*"
Notice that the Wedge's '@' is not
included in the PRINT# 15 command.
The command above, of course, assumes
that the Command/Error channel has
been previously OPENed as Logical File
number 15.
By INPUTting from the Command/Error
channel (with an INPUT# command), the
Disk Drive Status can be obtained.
The following command:
INPUT #15, ER%, ER$, ET%, EB%
will assign the Error Code Number to
ER%, the Error Message itself to ER$,
the Track on which the error occurred
to ET%, and the Block number to EB%.
This is a very important command. It
allows the program to act on errors
that may happen during data access.
------- Continued in Part 11 ---------